<template>
  <view class="admin-dashboard">
    <!-- 快捷操作入口 -->
    <uni-card title="快捷操作">
      <view class="quick-actions">
        <view class="action-item" @click="navigateTo('/pages/admin/services')">
          <uni-icons type="list" size="30"/>
          <text>服务管理</text>
        </view>
        <view class="action-item" @click="navigateTo('/pages/admin/carousel')">
          <uni-icons type="image" size="30"/>
          <text>轮播图管理</text>
        </view>
      </view>
    </uni-card>
  </view>
</template>

<script>
import request from '@/utils/request.js'

export default {
  data() {
    return {
    }
  },
  
  onLoad() {
    // 检查是否是管理员
    const userInfo = uni.getStorageSync('userInfo')
    if (!userInfo || !userInfo.is_admin) {
      uni.showToast({
        title: '无权限访问',
        icon: 'none'
      })
      setTimeout(() => {
        uni.switchTab({
          url: '/pages/home/index'
        })
      }, 1500)
      return
    }
  },
  
  onShow() {
    // 检查管理员权限
    const userInfo = uni.getStorageSync('userInfo')
    if (!userInfo || !userInfo.is_admin) {
      uni.showToast({
        title: '无权限访问',
        icon: 'none'
      })
      setTimeout(() => {
        uni.switchTab({
          url: '/pages/home/index'
        })
      }, 1500)
      return
    }
  },
  
  methods: {
    navigateTo(url) {
      uni.navigateTo({ url })
    }
  }
}
</script>

<style lang="scss">
.admin-dashboard {
  padding: 20rpx;
  
  .stats-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20rpx;
    margin-bottom: 30rpx;
    
    .stats-num {
      font-size: 36rpx;
      font-weight: bold;
      color: #2979ff;
    }
  }
  
  .quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30rpx;
    padding: 20rpx 0;
    
    .action-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 20rpx;
      background: #f5f5f5;
      border-radius: 8rpx;
      
      text {
        margin-top: 10rpx;
        font-size: 28rpx;
      }
    }
  }
}
</style> 